package com.tomorrow.runner.util;

import com.tomorrow.runner.R;

import java.util.HashMap;
import java.util.Map;

import cn.sucun.android.log.Log;

/**
 * Created by tomorrow on 16-4-29.
 */
public class WeatherUtil {
    public static final Map<String,Integer> mWeatherIcon = new HashMap<>();
    public static final String SUNNY = "晴";
    public static final String CLOUDY = "云阴";
    public static final String WINDY = "风";
    public static final String SNOW = "雪冰";
    public static final String RAIN = "雨";
    static {
        mWeatherIcon.put(SUNNY,R.mipmap.sun);
        mWeatherIcon.put(CLOUDY,R.mipmap.cloud);
        mWeatherIcon.put(WINDY,R.mipmap.wind);
        mWeatherIcon.put(SNOW,R.mipmap.snow);
        mWeatherIcon.put(RAIN,R.mipmap.rain);
    }

    public static int getWeatherIconId(String weather) {
        Log.i("WeatherUtil","weather = " +weather);
        for (String key : mWeatherIcon.keySet()){
            if (key.length()>1){
                for (char d : key.toCharArray()){
                    if (weather.contains(d+"")){
                        return mWeatherIcon.get(key);
                    }
                }
            }
            else{
                if (weather.contains(key)){
                    return mWeatherIcon.get(key);
                }
            }
        }
        return mWeatherIcon.get(SUNNY);
    }
}
